The Flash Objects API > Flash objects overview > SWFFile.createFile()

 

SWFFile.createFile()

Description

Generates a new Flash Object file with the specified template and array of parameters. Also creates a GIF, PNG, JPEG, and MOV version of the title if file names for those formats are specified.

If you want to specify an optional parameter that comes after optional parameters you do not want to specify, you need to specify empty strings for the parameters you don't want to specify. For example, if you want to specify a .png file, but not a .gif file, you'd need to specify an empty string before specifying the .png file name.

Arguments

templateFile, templateParams, swfFileName, {gifFileName}, {pngFileName}, {jpgFileName}, {movFileName}, {generatorParams}

templateFile is a path to a Template file, expressed as a file://URL. This file can be a .swt file.
templateParams is an array of name/value pairs where the names are the names of the parameters in the .swt file and the values are what you want to set those parameters to be. For an .swf file to be recognized by Dreamweaver as a Flash object, the first parameter must be "dwType". Its value should be a string representing the name of the object type, such as "Flash Text".
swfFileName is the output file name of an .swf file name, expressed as a file://URL, or an empty string to ignore.
{gifFileName} is the output file name of a .gif file name, expressed as a file://URL. Optional.
{pngFileName} is the output file name of a .png file name, expressed as a file://URL. Optional.
{jpgFileName} is the output file name of a .jpeg file name, expressed as a file://URL. Optional.
{movFileName} is the output file name of a QuickTime movie file name, expressed as a file://URL. Optional.
{generatorParams} is an array of strings representing optional Generator command line flags. Optional. Each flag must be followed in the array by its data items. Some commonly used flags are listed in the following table.
Option Flag Data Description Example

-defaultsize

width, height

Sets the output image size to the specified width and height.

"-defaultsize", "640", "480"

-exactFit

none

Stretches the contents in the output image to fit exactly into the specified output size.

"-exactFit"


Returns

A string containing one of the following values:

"noError" means the call completed successfully.
"invalidTemplateFile" means the specified Template file was invalid or not found.
"invalidOutputFile" means at least one of the specified output file names was invalid.
"invalidData" means that one or more of the templateParams was invalid.
"initGeneratorFailed" means Generator could not be initialized.
"outOfMemory" means insufficient memory to complete the operation.
"unknownError" means an unknown error occurred.

Example

The following JavaScript creates a Flash Object file of type "myType" that replaces any occurrence of "text" inside the Template file with "Hello World". It will create a .gif file as well as an .swf file.

var params = new Array;
params[0] = "dwType";
params[1] = "myType";
params[2] = "text";
params[3] = "Hello World";
errorString = SWFFile.createFile( "file:///MyMac/test.swt", ¬
params, "file:///MyMac/test.swf", "file:///MyMac/test.gif");